<%@page import="com.sun.image.codec.jpeg.JPEGCodec"%>
<%@page import="com.sun.image.codec.jpeg.JPEGImageEncoder"%>
<%@page import="captcha.Captcha"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.awt.Graphics2D"%>
<%
    BufferedImage bi = new BufferedImage(200, 50, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics();

    Captcha.drawCaptcha(g, request);

    g.dispose();

    ServletOutputStream sos = response.getOutputStream();
    JPEGImageEncoder jme = JPEGCodec.createJPEGEncoder(sos);

    jme.encode(bi);
%>